package com.ruoyi.employment.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.employment.domain.THangOver;
import com.ruoyi.employment.service.ITHangOverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 帮扶移交Controller
 * 
 * @author ruoyi
 * @date 2022-12-24
 */
@RestController
@RequestMapping("/handOver")
public class THangOverController extends BaseController
{
    @Autowired
    private ITHangOverService tHangOverService;

    /**
     * 查询帮扶移交列表
     */
    @RequiresPermissions("employment:handOver:list")
    @GetMapping("/list")
    public TableDataInfo list(THangOver tHangOver)
    {
        startPage();
        List<THangOver> list = tHangOverService.selectTHangOverList(tHangOver);
        return getDataTable(list);
    }

    /**
     * 导出帮扶移交列表
     */
    @RequiresPermissions("employment:handOver:export")
    @Log(title = "帮扶移交", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, THangOver tHangOver)
    {
        List<THangOver> list = tHangOverService.selectTHangOverList(tHangOver);
        ExcelUtil<THangOver> util = new ExcelUtil<THangOver>(THangOver.class);
        util.exportExcel(response, list, "帮扶移交数据");
    }

    /**
     * 获取帮扶移交详细信息
     */
    @RequiresPermissions("employment:handOver:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tHangOverService.selectTHangOverById(id));
    }

    /**
     * 新增帮扶移交
     */
    @RequiresPermissions("employment:handOver:add")
    @Log(title = "帮扶移交", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody THangOver tHangOver)
    {
        return toAjax(tHangOverService.insertTHangOver(tHangOver));
    }

    /**
     * 修改帮扶移交
     */
    @RequiresPermissions("employment:handOver:edit")
    @Log(title = "帮扶移交", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody THangOver tHangOver)
    {
        return toAjax(tHangOverService.updateTHangOver(tHangOver));
    }

    /**
     * 删除帮扶移交
     */
    @RequiresPermissions("employment:handOver:remove")
    @Log(title = "帮扶移交", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tHangOverService.deleteTHangOverByIds(ids));
    }
}
